/**
 * Created by lt on 2017/5/3.
 */
$(function(){
    $("#form-member-add").validate({
        rules:{
            userName:{
                required:true,
                minlength:2,
                maxlength:16
            },
            realName:{
                required:true,
                minlength:2,
                maxlength:16
            },
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            $.ajax({
                cache:true,
                type:'POST',
                data:$('#form-member-add').serialize(),
                url:'/admin/user/modifyUser.html',
                //async:false,
                dataType:'json',
                success:function(data){
                    if (data.code != 1){
                        layer.msg('操作失败!',{icon : 5,time : 1000});
                        console.log(data.msg);
                        return;
                    }
                    layer.msg('操作成功!',{icon : 6,time : 1000},function(){
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    })
                }
            })
        }
    });
});